package cn.com.api.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.api.entity.ApiU_article_reply;
import cn.com.api.entity.U_article;
import cn.com.api.mapper.ApiU_article_replyMapper;
import cn.com.api.mapper.U_articleMapper;
import cn.com.api.service.ApiU_article_replyService;
import cn.com.api.service.impl.base.U_article_replyServiceImplBase;
import cn.com.util.PageInfo;

/**
 * 
 **/
@Service
public class ApiU_article_replyServiceImpl extends U_article_replyServiceImplBase implements ApiU_article_replyService{
	@Autowired
	private ApiU_article_replyMapper apiU_article_replyMapper;
	@Autowired
	private U_articleMapper u_articleMapper;
	
    //新增对象后返回记录ID
    public int U_article_replyInsertion(ApiU_article_reply u_article_reply)
    {
        return this.apiU_article_replyMapper.U_article_replyInsertion(u_article_reply);
    }
    
    //根据user_id查article_reply
    @Override
    public List<ApiU_article_reply> findU_article_replysByUserID(Map<String,String> map, PageInfo page)
    {
    	List<ApiU_article_reply> reply_list = this.apiU_article_replyMapper.findU_article_replysByMapListPage(map, page);
    	if(map.containsKey("user_id"))
    	{
	    	//放入article对象
	    	for(ApiU_article_reply article_reply : reply_list)
	    	{
	    		U_article article = u_articleMapper.getArticleWithoutContentById(Integer.valueOf(article_reply.getArticle_id()));
	    		article_reply.setArticle(article);
	    	}
    	}
    	return reply_list;
    }

	@Override
	public List<ApiU_article_reply> findU_article_replyListById(Integer id) {
		  // 根据id获取
					List<ApiU_article_reply> u_article_reply = apiU_article_replyMapper.findU_article_replyByListId(id);
					return u_article_reply;
	}
 
}


